<template>
    <div class="app-container">
        <main>
            <div style="height: 735px;">
                <el-table :data="tableData" border stripe height="100%">
                    <el-table-column prop="id" label="ID" width="180" align="center">
                        <template slot-scope="scope">
                            <span style="color: #4d4de2;cursor: pointer;"
                                @click="go(scope.row, 'http://jx.qida999.com/DriverCommon/system/JxArea.aspx')">{{
                                    scope.row.id }}</span>
                        </template>
                    </el-table-column>
                    <el-table-column prop="areaCode" label="区域代码" width="180" align="center" />
                    <el-table-column prop="areaName" label="区域名称" align="center" />
                    <el-table-column prop="cnt" label="客户数" align="center">
                        <template slot-scope="scope">
                            <span style="color: #4d4de2;cursor: pointer;"
                                @click="go2(scope.row, 'http://jx.qida999.com/DriverCommon/system/DrJx_find.aspx')">{{
                                    scope.row.cnt }}</span>
                        </template>
                    </el-table-column>
                </el-table>
            </div>
        </main>

        <!-- 分页 -->
        <footer class="pagin">
            <el-pagination background :current-page="params.page" :page-sizes="[20, 50, 100, 150]"
                layout="total, sizes, prev, pager, next, jumper" :total="total" @size-change="handleSizeChange"
                @current-change="handleCurrentChange" :page-size="params.pageSize" />
        </footer>
    </div>
</template>

<script>
import { adminAPI } from '@/api/adminstare'

/**
* @author        Yng
* @time          2023-11-03 10:15:19  星期五
* @description   区域信息
**/


export default {
    data() {
        return {
            tableData: [],
            total: 0,
            params: {
                action: 'jxAreaList',
                page: 1,
                pageSize: 20,
            },
        }
    },
    mounted() {
        this.getReconInfo()
    },
    methods: {
        async getReconInfo() {
            let { code, data, total } = await adminAPI(this.params)
            if (!code) {
                this.tableData = data
                this.total = total
            }
        },
        // 一页几条数据
        handleSizeChange(val) {
            this.params.pageSize = val
            this.getReconInfo();
        },
        // 当前页
        handleCurrentChange(val) {
            this.params.page = val
            this.getReconInfo();
        },
        go(val, URL) {
            const redirectUrl = `${URL}?id=${val.id}`
            this.$oldLoginSystem(redirectUrl)
        },
        go2(val, URL) {
            const redirectUrl = `${URL}?city=${val.areaCode}`
            this.$oldLoginSystem(redirectUrl)
        },
    }
}
</script>

<style lang="scss" scoped>
.app-container {
    main {
        &>div {
            height: 670px;
        }
    }
}
</style>